﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Kopain2.UserControls
{
    /// <summary>  This control is the editor control.  In the future it will hopefully be exchanged for a more versatile editor addin structure.
    /// </summary>
    public partial class EditorControl : UserControl
    {

#region	Constructors.

        /// <summary>The default constructor.
        /// </summary>
        public EditorControl()
        {
            InitializeComponent();
        }

#endregion	//	Constructors.

        /// <summary>This is teh getter for the text in plain form, without formatting.
        /// </summary>
        internal string PlainText
        {
            get
            {
                TextRange textrange = new TextRange(_rtfControl.Document.ContentStart, _rtfControl.Document.ContentEnd);
                return textrange.Text;
            }
        }

        /// <summary>This method fills the editor with the parameter.  Unformatted.
        /// </summary>
        /// <param name="text"></param>
        internal void Populate(string text)
        {
            Paragraph paragraph = new Paragraph();
            paragraph.Inlines.Add(text);
            _rtfControl.Document.Blocks.Clear();
            _rtfControl.Document.Blocks.Add(paragraph);
        }

    }
}
